package com.itheima.demo;

import java.util.Collections;
import java.util.Comparator;
import java.util.TreeSet;

public class Demo_Compara {
    public static void main(String[] args) {
        /*TreeSet<Integer> set = new TreeSet<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2-o1;
            }
        });*/
        //使用lambda表达式替换匿名内部类;
        TreeSet<Integer> set = new TreeSet<>((o1, o2) -> o2 - o1);
        Collections.addAll(set, 12, 34, 67, 4, 3, 1, 0, 8);
        System.out.println(set);
    }
}
